<?php

namespace app\admin\controller;

use app\admin\controller\Common;

class Config extends Common
{
    public function index()
    {
        if ($this->request->isAjax()) {
            $data = $this->request->post();
            foreach ($data as $key => $value) {
                if (in_array($key, ['img'])) continue;
                sysConfig($key, $value);
            }
            return ['ret' => '保存成功'];
        }
        return $this->fetch();
    }

    /**
     * User:Simony
     * Function: 第三方配置
     * @return array|mixed
     */
    public function thirdParty()
    {
        if ($this->request->isAjax()) {
            $data = $this->request->post();
//            print_r($data);die;
            foreach ($data as $key => $value) {
                sysConfig($key, $value);
            }
            return ['ret' => '保存成功'];
        }
        return $this->fetch();
    }


    /**
     * User:Simony
     * Function: 平台配置
     * @return array|mixed
     */
    public function platform()
    {
        if ($this->request->isAjax()) {
            $data = $this->request->post();
            if(isset($data['public_key'])) unset($data['public_key']);
            if(isset($data['private_key']))unset($data['private_key']);

            foreach ($data as $key => $value) {
                sysConfig($key, $value);
            }
            return ['ret' => '保存成功'];
        }

        $sexs = model('common/member/member')->sexs;
        $this->assign('sexs', $sexs);
        return $this->fetch();
    }
}
